package day5;

import java.util.Scanner;

public class Main1 {
    /**
     * BC138 矩阵转置
     * https://www.nowcoder.com/practice/351b3d03e410496ab5a407b7ca3fd841?tpId=290&tqId=39926&ru=/exam/oj
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[][] arr = new int[n][m];
        for(int i = 0;i < n;i++) {
            for(int j = 0;j < m;j++) {
                arr[i][j] = in.nextInt();
            }
        }

        for(int i = 0;i < m;i++) {
            for(int j = 0;j < n;j++) {
                System.out.print(arr[j][i] + " ");
            }
            System.out.println("");
        }
    }
}
